package com.alibaba.algo.config;

import com.alibaba.algo.utils.JedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @author xuxueli 2018-04-03 20:41:07
 */
@Configuration
@Slf4j
public class RedisConfig implements InitializingBean, DisposableBean {

    @Value("${xxl.sso.redisAddress}")
    private String redisAddress;

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("redisAddress={}", redisAddress);
        JedisUtil.init(redisAddress);
    }

    @Override
    public void destroy() throws Exception {
        JedisUtil.close();
        log.info("JedisUtil closed");
    }
}
